<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import = "java.util.*" %>
<%@ page import = "cs5300.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>CS 5300 project 1b</title>
</head>
<body>
<% 
	SessionManager sm = SessionManager.getInstance();
	sm.update(request,response);
	out.println(indexDisplayWrapper.message);
/*
	boolean hasCookie = false;
	Cookie cookies[] =  request.getCookies();
	if(cookies == null){
		hasCookie = false;
	}else{
		for(int i = 0; i < cookies.length; i++){
			if(cookies[i].getName().equals(SessionManager.CookieName)){
				if(SessionManager.validCookie(cookies[i])){
					hasCookie = true;
					SessionManager.UpdateCookie(cookies[i],false,null);
					int seID = sessionState.getSessionState(cookies[i].getValue()).SesssionID;
					sessionState ss = SessionManager.getSessionState(seID);
					request.setAttribute("messegeText", ss.message);
					request.setAttribute("bottomText", SessionManager.getSessionTimeString(seID));
				}
			}
		}
	}
	if(!hasCookie){
		Cookie cookie = SessionManager.getNewCookie();
		int seID = sessionState.getSessionState(cookie.getValue()).SesssionID;
		sessionState ss = SessionManager.getSessionState(seID);
		request.setAttribute("messegeText", ss.message);
		request.setAttribute("bottomText", SessionManager.getSessionTimeString(seID));
		response.addCookie(cookie);
	}
	String ReplaceText = (String)request.getAttribute("messegeText");
		if(ReplaceText != null){
			out.println("<h1>" + ReplaceText + "</h1>");
	}
		*/
%>

<form method="POST" action="Replace.do">
<input type="SUBMIT" value="Replace">
<input type="text" name="ReplaceText">
</form>
<br>
<form method="POST" action="Refresh.do">
<input type="SUBMIT" value="Refresh">
</form>
<br>
<form method="POST" action="Logout.do">
<input type="SUBMIT" value="log out">
</form>
<br>
<form method="POST" action="Crash.do">
<input type="SUBMIT" value="Crash a Server">
</form>


<h1>The serverID of the server executing the client request.</h1>
<%
	out.println(indexDisplayWrapper.ServerIDEXE);
%>
<br>
<h1>where the session data was found </h1>
<%
	out.println(indexDisplayWrapper.ServerFound);
%>
<br>

<h1>discard_time for a new or updated session</h1>
<%
	out.println(indexDisplayWrapper.DiscardTime);
%>
<br>

<h1>The sessionID that was evicted from the cache (if any).</h1>
<%
	out.println(indexDisplayWrapper.evict);
%>
<br>

<h1>The entire MbrSet</h1>
<%
	out.println(indexDisplayWrapper.MbrSet);
%>
<br>

</body>
</html>